package com.example.gokuplayalong.bases.custom;

import android.graphics.Bitmap;
import android.os.Message;
 import android.webkit.WebResourceError;
import android.webkit.WebResourceRequest;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.example.gokuplayalong.MainActivity;


public class CustomWebViewClient extends WebViewClient {
    @Override
    public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
        super.onReceivedError(view, request, error);
        Message message = new Message();
        message.what = -2;
        MainActivity.getInstance().handler.sendMessage(message);
    }

    @Override
    public void onPageCommitVisible(WebView view, String url) {
        super.onPageCommitVisible(view, url);
    }

    @Override
    public void onPageStarted(WebView view, String url, Bitmap favicon) {
        super.onPageStarted(view, url, favicon);
        Message message = new Message();
        message.what = 1;
        MainActivity.getInstance().handler.sendMessage(message);
    }

    @Override
    public void onPageFinished(WebView view, String url) {
        super.onPageFinished(view, url);
        Message message = new Message();
        message.what = 2;
        MainActivity.getInstance().handler.sendMessage(message);

    }
}
